package com.example.tests.logic;


public class User implements Comparable<User>{
	private String username;
	private String email;
	private String password;
	private String role;
	public User() {
		
	}
	public User(String name,String mail,String pass,String rol) {
		username = name;
		email = mail;
		password = pass;
		role = rol;
	}
	public String getUsername() {
		return username;
	}
	public User withUsername(String username) {
		this.username = username;
		return this;
	}
	public String getEmail() {
		return email;
	}
	public User withEmail(String email) {
		this.email = email;
		return this;
	}
	public String getPassword() {
		return password;
	}
	public User withPassword(String password) {
		this.password = password;
		return this;
	}
	public String getRole() {
		return role;
	}
	public User withRole(String role) {
		this.role = role;
		return this;
	}
	@Override
	public int compareTo(User otherUser) {
		return this.username.compareTo(otherUser.username);
	}
	@Override
	public String toString() {
		return "User [username=" + username + ", email=" + email + "]";
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((email == null) ? 0 : email.hashCode());
		result = prime * result
				+ ((username == null) ? 0 : username.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (email == null) {
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		if (username == null) {
			if (other.username != null)
				return false;
		} else if (!username.equals(other.username))
			return false;
		return true;
	}
}
